package com.resp;

//404 资源部存在
// 40001  用户已存在
// 40002 注册失败
// 40004 服务器繁忙! 请稍后再试


public class BaseResponseEntity<T> {
    private int status;
    private String msg;
    private T date;
    private String name;
    private int sum;


    public BaseResponseEntity(int status, String msg, T date) {
        this.status = status;
        this.msg = msg;
        this.date = date;
    }
    public BaseResponseEntity(int status, String msg, T date,int sum) {
        this.status = status;
        this.msg = msg;
        this.date = date;
        this.sum=sum;
    }



    public BaseResponseEntity(int status, String msg, T date, String name) {
        this.status = status;
        this.msg = msg;
        this.date = date;
        this.name = name;
    }

    public BaseResponseEntity() {};


    public static <T> BaseResponseEntity error(int status, String msg) {
        BaseResponseEntity baseResponseEntity = new BaseResponseEntity();
        baseResponseEntity.setStatus(status);
        baseResponseEntity.setMsg(msg);
        return baseResponseEntity;
    }

    public static <T> BaseResponseEntity error() {
        return error(404, "密码错误");
    }

    public static <T> BaseResponseEntity Usernull() {
        return error(408, "请先登陆");
    }


    public static <T> BaseResponseEntity findPhonError() {
        return error(406, "数据库无数据");
    }

    public static <T> BaseResponseEntity rebug() {
        return error(405, "账户已存在，注册失败");
    }

    public static <T> BaseResponseEntity AddCartBug(){
        return error(407,"加入购物车失败");
    }

    public static <T> BaseResponseEntity nullCart(){
        return error(409,"购物车无订单");
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getDate() {
        return date;
    }

    public void setDate(T date) {
        this.date = date;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
